package com.superdry.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.ab.activity.AbActivity;
import com.ab.http.AbHttpUtil;
import com.ab.http.AbStringHttpResponseListener;
import com.ab.util.AbToastUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.drysurper.R;
import com.superdry.utils.GlobalConst;

public class ProblemActivity extends AbActivity{

	View goback;
	TextView problem_tv;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setAbContentView(R.layout.aty_problem);
		
		problem_tv = (TextView) findViewById(R.id.problem_tv);
		goback = findViewById(R.id.goback_problem);
		
		getProblem();
		goback.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}
	
	public void getProblem(){
		
		AbHttpUtil http = AbHttpUtil.getInstance(ProblemActivity.this);
		http.setTimeout(1000*5);
		http.post(GlobalConst.PROBLEM+"?i=2", new AbStringHttpResponseListener() {
			
			@Override
			public void onStart() {
				
			}
			
			@Override
			public void onFinish() {
				
			}
			
			@Override
			public void onFailure(int statusCode, String content, Throwable error) {
				AbToastUtil.showToast(ProblemActivity.this, error.getMessage());
			}
			
			@Override
			public void onSuccess(int statusCode, String content) {
				JSONObject jo = (JSONObject) JSON.toJSON(content);
				String problem = (String) jo.get("content");
				problem_tv.setText(problem);
			}
		});
		
	}
}

